# HTTP basic auth case
import json
import urllib.parse
import urllib.request

if __name__ == '__main__':
    # get 传参
    params = urllib.parse.urlencode({'current': 1, 'size': 10})
    url = 'http://httpbin.org/get?%s' % params
    with urllib.request.urlopen(url) as f:
        print(json.load(f))
    # post传参
    data = urllib.parse.urlencode({'current': 1, 'size': 10})
    data = data.encode()
    url1 = 'http://httpbin.org/post'
    with urllib.request.urlopen(url1, data) as p:
        print(json.load(p))